#include "SoundEngine.h"
#include "SDL_mixer.h"

SoundEngine::SoundEngine(void)
{
	int audio_rate = 22050;
	Uint16 audio_format = AUDIO_S16;
	int audio_channels = 2;
	int audio_buffers = 4096;
	Mix_OpenAudio(audio_rate,audio_format,audio_channels,audio_buffers);
	Mix_QuerySpec(&audio_rate,&audio_format,&audio_channels);	
}

void SoundEngine::przegrana()
{
	Mix_HaltMusic();
	lose = Mix_LoadMUS("/Audio/przegrana.wav");
	Mix_PlayMusic(lose,0);
	glowna();
}

void SoundEngine::pierwsze_wejscie()
{
	Mix_HaltMusic();
	wejscie = Mix_LoadMUS("/Audio/wejscie_do_gry.wav");
	Mix_PlayMusic(wejscie,0);
	glowna();
}

void SoundEngine::strzal1()
{
	pistolet = Mix_LoadWAV("/Audio/strzal.wav");
	Mix_PlayChannel(-1,pistolet,0);
}

void SoundEngine::morderstwo()
{
	kill = Mix_LoadWAV("/Audio/kill.wav");
	Mix_PlayChannel(-1,kill,0);
}

void SoundEngine::smierc()
{
	dead1 = Mix_LoadWAV("/Audio/dead1.wav");
	dead2 = Mix_LoadWAV("/Audio/dead2.wav");
	Mix_PlayChannel(-1,dead1,0);
	Mix_PlayChannel(-1,dead2,0);
}

void SoundEngine::win()
{
	Mix_HaltMusic();
	wygrana = Mix_LoadMUS("/Audio/wygrana.mp3");
	Mix_PlayMusic(wygrana,0);
	glowna();
}

void SoundEngine::menusy()
{
	Mix_HaltMusic();
	menu = Mix_LoadMUS("");
	Mix_PlayMusic(menu,-1);
}

void SoundEngine::glowna()
{
	Mix_HaltMusic();
	gra = Mix_LoadMUS("");
	Mix_PlayMusic(gra,-1);
}

SoundEngine::~SoundEngine(void)
{
	Mix_HaltMusic();
	Mix_CloseAudio();
}
